package com.lesson5.prototype;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/8/27 20:52
 */
public class Client
{
    public static void main(String[] args) throws CloneNotSupportedException
    {
//        Sheep sheep = new Sheep("duoli", 1, "白色");
//        try
//        {
//            sheep.sheep = new Sheep("andy",2,"紫色");
//            Sheep clone1 = (Sheep) sheep.clone();
//            Sheep clone2 = (Sheep) sheep.clone();
//            Sheep clone3 = (Sheep) sheep.clone();
//            Sheep clone4 = (Sheep) sheep.clone();
//
////            System.out.println(sheep);
//            System.out.println("clone1="+clone1+"clone1.sheep="+sheep.sheep.hashCode());
//            System.out.println("clone2="+clone2+"clone2.sheep="+sheep.sheep.hashCode());
//            System.out.println("clone3="+clone3+"clone3.sheep="+sheep.sheep.hashCode());
//            System.out.println("clone4="+clone4+"clone4.sheep="+sheep.sheep.hashCode());
//        } catch (CloneNotSupportedException e)
//        {
//            e.printStackTrace();
//        }
        DeepPrototype deepPrototype = new DeepPrototype();
        deepPrototype.name = "宋江";
        deepPrototype.target = new DeepCloneableTarget("大牛","大牛的类");

        DeepPrototype p2 = (DeepPrototype) deepPrototype.clone();

        System.out.println(deepPrototype.hashCode()==p2.hashCode());
    }
}
